package com.liujit.upms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liujit.upms.domain.model.SysPermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description 系统权限Mapper
 * @Author liujun
 * @Date 2021-07-02 15:00:56
 */
@Mapper
public interface SysPermissionMapper extends BaseMapper<SysPermission> {

    /**
     * 根据用户id，查询权限列表
     *
     * @param userId 用户id
     * @return 权限列表
     * @author: liujun
     * @date: 2021/7/4 10:02 上午
     */
    @Select("select sp.btn_permission from"
            + " (select distinct srp.permission_id from sys_user_role sur inner join sys_role_permission srp on srp.role_id = sur.role_id where sur.user_id = #{userid}) t"
            + " inner join sys_permission sp on sp.id = t.permission_id and sp.enabled = 1")
    List<String> selByUserId(Long userId);
}